LL_PLAY_DeInit APIs migration ¶
The LL initialization and de-initialization functions previously available in the
stm32tnxx_ll_play.c
files
within HAL1 are no longer present in HAL2.
In HAL2, all LL C files (
stm32tnxx_ll_play.c) have been removed, leaving only the LL header files (
stm32tnxx_ll_play.h)
that contain static inline functions.
If users need to initialize or de-initialize play using the LL layer, they have two methods:
Utilize STM32CubeMX2 Code Generation: Rely on STM32CubeMX2 to generate code with the LL layer for play initialization and de-initialization.
- Replace manually the de-initialization functionReplace the
LL_play_DeInitfunction manually with equivalent sequences using the static inline functions provided in the
stm32tnxx_ll_play.hfile, tailored to their specific configuration and requirements.
- Replace manually the de-initialization functionReplace the
This approach ensures that the de-initialization sequences are precisely addressing the given use case based on the LL static inline functions provided in the
stm32tnxx_ll_play.h
header file.
The sequences offer improved footprint optimization compared to the previous LL initialization functions found in
stm32tnxx_ll_play.c.
Related concept: Remove stm32tnxx_ll_ppp.c files
Method 1: Utilize STM32CubeMX2 Code Generation ¶
LL PLAY configuration panel ¶
Create a new project with the STM32CubeMX2, then start the initialization and the main configuration.
HAL PLAY main features configuration ¶
Configure the PLAY main features.
HAL PLAY GPIO configuration ¶
Configure GPIO pins.
HAL PLAY EXTI configuration ¶
Configure the EXTI.
HAL PLAY NVIC configuration ¶
Configure the NVIC in case of an interrupt.
Generated PLAY initialization and de-initialization sequences ¶
The PLAY initialization sequence is generated in the
mx_play_init
and the
mx_play_deinit
function in the
mx_play.c
file under
$YOUR_PROJECT_NAME$/$YOUR_PROJECT_NAME$_SW/generated/STM32Cube_CodeGen.
Related concepts:
|
Topic |
Code Snippet HAL1 |
Code Snippet HAL2 |
|---|---|---|
|
Init and config sequence function |
void MX_PLAY1_Init(void)
{
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
/* Peripheral clock source */
LL_RCC_SetPLAY1ClockSource(LL_RCC_PLAY1_CLKSOURCE_LSE);
/* Peripheral clock enable */
LL_APB3_GRP1_EnableClock(LL_APB3_GRP1_PERIPH_PLAY1);
LL_APB3_GRP1_EnableClock(LL_APB3_GRP1_PERIPH_PLAY1APB);
/* PLAY input configuration */
LL_PLAY_INPUT_Config(PLAY1, LL_PLAY_IN0, 0, LL_PLAY_EDGE_DETECTION_MODE_BYPASSED, 0);
/* PLAY LUT0 configuration */
LL_PLAY_LUT_SetTruthTable(PLAY1, LL_PLAY_LUT0, 0x0000);
/* Unused inputs are connected to SW trigger 15 */
LL_PLAY_LUT_ConfigInputs(PLAY1, LL_PLAY_LUT0, LL_PLAY_LUT_SOURCE_SWTRIG15,
LL_PLAY_LUT_SOURCE_SWTRIG15, LL_PLAY_LUT_SOURCE_SWTRIG15,
LL_PLAY_LUT_SOURCE_SWTRIG15, LL_PLAY_LUT_CLK_GATE_OFF);
/* Connect LUT0 output to PLAY output 0 */
LL_PLAY_OUTPUT_SetSource(PLAY1, LL_PLAY_OUT0, LL_PLAY_LUT0_OUT_DIRECT);
/* GPIO Clocks activation */
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOB);
/**
PLAY1 GPIO Configuration
PB11 ------> PLAY1_IN2
**/
GPIO_InitStruct.Pin = LL_GPIO_PIN_11;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_14;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* EXTI line configuration */
LL_EXTI_EnableRisingTrig_32_63(LL_EXTI_LINE_51);
LL_EXTI_DisableFallingTrig_32_63(LL_EXTI_LINE_51);
/* PLAY1 interrupt Init */
NVIC_SetPriority(PLAY1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
NVIC_EnableIRQ(PLAY1_IRQn);
}
|
PLAY_TypeDef *mx_play1_init(void)
{
/* Peripheral clock source */
LL_RCC_SetPLAYClockSource(LL_RCC_PLAY1_CLKSOURCE_LSE);
/* Peripheral clock enable */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_PLAY1);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_PLAY1APB);
/* PLAY input configuration */
LL_PLAY_INPUT_Config(PLAY1, LL_PLAY_IN0, 0U, LL_PLAY_EDGE_DETECTION_MODE_BYPASSED, 0U);
/* PLAY LUT0 configuration */
LL_PLAY_LUT_SetTruthTable(PLAY1, LL_PLAY_LUT0, 0x00);
/* Unused inputs are connected to SW trigger 15 */
LL_PLAY_LUT_ConfigInputs(PLAY1, LL_PLAY_LUT0, LL_PLAY_LUT_SOURCE_SWTRIG15,
LL_PLAY_LUT_SOURCE_SWTRIG15, LL_PLAY_LUT_SOURCE_SWTRIG15,
LL_PLAY_LUT_SOURCE_SWTRIG15, LL_PLAY_LUT_CLK_GATE_OFF);
/* Connect LUT0 output to PLAY output 0 */
LL_PLAY_OUTPUT_SetSource(PLAY1, LL_PLAY_OUT0, LL_PLAY_LUT0_OUT_DIRECT);
/* GPIO Clocks activation */
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOB);
/**
PLAY1 GPIO Configuration
PB11 ------> PLAY1_IN2
**/
LL_GPIO_SetPinMode(GPIOB, LL_GPIO_PIN_11, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinSpeed(GPIOB, LL_GPIO_PIN_11, LL_GPIO_SPEED_FREQ_LOW);
LL_GPIO_SetPinOutputType(GPIOB, LL_GPIO_PIN_11, LL_GPIO_OUTPUT_PUSHPULL);
LL_GPIO_SetPinPull(GPIOB, LL_GPIO_PIN_11, LL_GPIO_PULL_NO);
LL_GPIO_SetAFPin_8_15(GPIOB, LL_GPIO_PIN_11, LL_GPIO_AF_14);
/* EXTI line configuration */
LL_EXTI_EnableRisingTrig_32_63(LL_EXTI_LINE_51);
LL_EXTI_DisableFallingTrig_32_63(LL_EXTI_LINE_51);
/* PLAY1 interrupt Init */
NVIC_SetPriority(PLAY1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0));
NVIC_EnableIRQ(PLAY1_IRQn);
return PLAY1;
}
|
|
Deinit sequence function |
void MX_PLAY1_DeInit(void)
{
if (LL_PLAY_DeInit(PLAY1) != HAL_OK)
{
Error_Handler();
}
}
|
void mx_play1_deinit(void)
{
NVIC_DisableIRQ(PLAY1_IRQn);
LL_APB2_GRP1_DisableClock(LL_APB2_GRP1_PERIPH_PLAY1APB);
LL_APB2_GRP1_DisableClock(LL_APB2_GRP1_PERIPH_PLAY1);
LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_PLAY1);
LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_PLAY1);
LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_PLAY1APB);
LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_PLAY1APB);
LL_EXTI_DisableIT_32_63(LL_EXTI_LINE_51);
LL_EXTI_DisableEvent_32_63(LL_EXTI_LINE_51);
LL_EXTI_DisableRisingTrig_32_63(LL_EXTI_LINE_51);
LL_EXTI_DisableFallingTrig_32_63(LL_EXTI_LINE_51);
LL_EXTI_ClearRisingFlag_32_63(LL_EXTI_LINE_51);
LL_EXTI_ClearFallingFlag_32_63(LL_EXTI_LINE_51);
}
|
Method 2: Replace manually the de-initialization functions ¶
LL_PLAY_DeInit() API migration ¶
According to the used PLAY instance, implement the precise calls to LL_APB2_GRP1_ForceReset() and LL_APB2_GRP1_ReleaseReset().
|
HAL1 |
HAL2 |
|---|---|
LL_PLAY_DeInit(PLAY1);
|
LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_PLAY1);
LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_PLAY1);
|